package org.exhaust.framework.net.test.protocol.util;

import cn.hutool.core.codec.BCD;

public class ByteUtils {
    public static String patchLength2Zero(String str, int length) {
        int zeroLength = length - str.length();
        if (zeroLength <= 0) {
            return str;
        } else {
            StringBuilder sb = new StringBuilder(length);
            for (int i = 0; i < zeroLength; i++) {
                sb.append("0");
            }
            sb.append(str);
            return sb.toString();
        }
    }

    public static byte[] str2Bcd(String str) {
        return BCD.strToBcd(str);
    }
}
